package com.hdl.servlet.address;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;

import com.hdl.R;
import com.hdl.entity.HdlUser;
import com.hdl.entity.MallAddress;
import com.hdl.exception.CodeException;
import com.hdl.service.MallAddressService;
import com.hdl.service.impl.MallAddressServiceImpl;
import com.hdl.servlet.HttpServletSupport;

/**
 * <pre>
 * - JSON控制器
 * - 商城用户收货地址
 * ClassName : com.hdl.servlet.address.MallAddressServlet
 * @author 湛锋
 * Date : 2020-8-24 11:08:19
 * </pre>
 */
@SuppressWarnings("serial")
@WebServlet("/mall-address.let")
public class MallAddressServlet extends HttpServletSupport {
	
	private MallAddressService mallAddressService = new MallAddressServiceImpl();
	
	/**
	 * 获取当前登录用户的地址列表
	 * @param user
	 * @return
	 * @throws Exception
	 */
	public Object execute(HdlUser user)throws Exception {
		if(user==null){
			throw new CodeException(401, "用户未登录");
		}
		MallAddress mallAddress = new MallAddress();
		mallAddress.setHdlUserId(user.getHdlUserId());
		return R.ok(mallAddressService.list(mallAddress, 999));
	}
}